package com.xindaoapp.henghua.view;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.xindaoapp.henghua.R;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

/**
 * 为画廊定义适配器
 */
public class HSVAdapter extends BaseAdapter {

	private List<Map<String,String>> list;
	private Context context;
	public HSVAdapter(Context context){
		this.context=context;
		this.list=new ArrayList<Map<String,String>>();
	}
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Map<String,String> getItem(int location) {
		return list.get(location);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	public void addObject(Map<String,String> map){
		list.add(map);
		notifyDataSetChanged();
	}
	
	public List<Map<String,String>> getUrls(){
		return this.list ;
	}
	
	public void setUrls(String[] urls){
		notifyDataSetChanged();
	}
	
	@Override
	public View getView(int location, View arg1, ViewGroup arg2) {
		View view = LayoutInflater.from(context).inflate(R.layout.layout_item_hsv,null);
		ImageView image=(ImageView)view.findViewById(R.id.movie_image);
		
		Map<String,String> map=getItem(location); 
		String uri = map.get("uri");
		ImageLoader.getInstance().displayImage(uri, image);
		
		
		return view;
	}

}
